var index1 =2;
var index2 =2;
var index3 =2;


$(function(){
    $("#icon11").bind("click",function(){
            addWork(1,'','',1);
        });
        $("#icon21").bind("click",function(){
            addWork(2,'','',1);
        });
        $("#icon31").bind("click",function(){
            addWork(3,'','',1);
        });
    initTable();
});
function addWork(type,content,indexid,addType){
    //根据class判断是删除还是新增一行
    if(addType==1){//新增
        var s1="<div id=\"workContent"+type+index1+"\" class=\"row_pop_row\"><div class=\"pop_lf\">日常工作</div><div class=\"pop_rt\"><div class=\"pop_rt_main pop_rt_main1\"><textarea rows=\"2\" id=\"content1"+index1+"\" name=\"content1"+index1+"\">"+content+"</textarea></div></div><div class=\"rili_add\"  id=\"icon1"+index1+"\" ></div></div>"
        var s2="<div id=\"workContent"+type+index2+"\" class=\"row_pop_row\"><div class=\"pop_lf\">重点工作</div><div class=\"pop_rt\"><div class=\"pop_rt_main pop_rt_main1\"><textarea rows=\"2\" id=\"content2"+index2+"\" name=\"content2"+index2+"\">"+content+"</textarea></div></div><div class=\"rili_add\"  id=\"icon2"+index2+"\" ></div></div>"
        var s3="<div id=\"workContent"+type+index3+"\" class=\"row_pop_row\"><div class=\"pop_lf\">交办工作</div><div class=\"pop_rt\"><div class=\"pop_rt_main pop_rt_main1\"><textarea rows=\"2\" id=\"content3"+index3+"\" name=\"content3"+index3+"\">"+content+"</textarea></div></div><div class=\"rili_add\"  id=\"icon3"+index3+"\" ></div></div>"
        //var s1="<div id=\"workContent"+type+index1+"\" class=\"row_pop_row\"><div class=\"pop_lf\">日常工作</div> <div class=\"pop_rt\"> <div class=\"pop_rt_main\"> <input type=\"text\" class=\"inpt\" name=\"content1"+index1+"\" id=\"content1"+index1+"\" value=\""+content+"\" /> <input type=\"hidden\" name=\"type"+index1+"\" value=\"1\" /> </div> </div><div class=\"rili_add\" id=\"icon1"+index1+"\" ></div></div>";
        //var s2="<div id=\"workContent"+type+index2+"\"  class=\"row_pop_row\"><div class=\"pop_lf\">重点工作</div> <div class=\"pop_rt\"> <div class=\"pop_rt_main\"> <input type=\"text\" class=\"inpt\" name=\"content2"+index2+"\" id=\"content2"+index2+"\" value=\""+content+"\" /> <input type=\"hidden\" name=\"type"+index2+"\" value=\"2\" /> </div> </div><div class=\"rili_add\"  id=\"icon2"+index2+"\" ></div></div>";
        //var s3="<div id=\"workContent"+type+index3+"\"  class=\"row_pop_row\"><div class=\"pop_lf\">交办工作</div> <div class=\"pop_rt\"> <div class=\"pop_rt_main\"> <input type=\"text\" class=\"inpt\" name=\"content3"+index3+"\" id=\"content3"+index3+"\" value=\""+content+"\" /> <input type=\"hidden\" name=\"type"+index3+"\" value=\"3\" /> </div> </div><div class=\"rili_add\"  id=\"icon3"+index3+"\" ></div></div>";

        if(type==1){
            var i = type+""+(index1-1);
            $("#workContent"+i).after(s1);
            $("#icon"+i).removeClass("rili_add");
            $("#icon"+i).addClass("rili_reduce");
            $("#icon"+i).unbind();
            $("#icon"+i).bind("click",function(){
                $("#workContent"+i).remove();
            });
            $("#icon"+type+""+index1).bind("click",function(){
                addWork(1,'','1'+index1,1);
            });
            index1++;
        }else if(type==2){
            var i = type+""+(index2-1);
            $("#workContent"+i).after(s2);
            $("#icon"+i).removeClass("rili_add");
            $("#icon"+i).addClass("rili_reduce");
            $("#icon"+i).unbind();
            $("#icon"+i).bind("click",function(){
                $("#workContent"+i).remove();
            });
            $("#icon"+type+""+index2).bind("click",function(){
                addWork(2,'','2'+index2,1);
            });
            index2++;
        }else if(type==3){
            var i = type+""+(index3-1);
            $("#workContent"+i).after(s3);
            $("#icon"+i).unbind();
            $("#icon"+i).removeClass("rili_add");
            $("#icon"+i).addClass("rili_reduce");
            $("#icon"+i).bind("click",function(){
                $("#workContent"+i).remove();
            });
            $("#icon"+type+""+index3).bind("click",function(){
                addWork(3,'','3'+index3,1);
            });
            index3++;
        }

    }else if(addType==2){//删除
        $("#workContent"+indexid).remove();
    }
}